home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / cnet / RRR_RH02.lha / Hydra / RHydra.rexx < prev   
OS/2 REXX Batch file  |  1995-04-26  |  12KB  |  292 lines

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*                                                                         */
  4. /*              R A I N B O W   H Y D R A   v0.2   by R R R                */
  5. /*                                                                         */
  6. /*                                                                         */
  7. /*            Based on FLUX POINT fphydra v0.2 - Thanks boys!              */
  8. /*                                                                         */
  9. /*                        Released 26-apr-95                               */
  10. /*                                                                         */
  11. /*    Always remember that Rainbow Hydra is named after the most famous    */
  12. /*  Rainbow Dragon, which is a cunning enemy and a marvelous dwarf eater.  */
  13. /*                                                                         */
  14. /*   Adventurers! Resistance is useless! Rainbow Hydra is here and it's    */
  15. /*                  going to devour your very livers!                      */
  16. /*                                                                         */
  17. /*                      RHydra Development team                            */
  18. /*                                                                         */
  19. /*                      Programming: Tailgunner                            */
  20. /*                   On-site testing: Sorsselsson                          */
  21. /*                      PC Test client: Verlorc                            */
  22. /*                                                                         */
  23. /*                  Contact - rrr@klinja.fipnet.fi                         */
  24. /*                                                                         */
  25. /***************************************************************************/
  26. /*             CONFIG - Modify these to suit your needs                    */
  27.  
  28.  
  29. usecur=0                            /* Use CURRENT AREA for uploads?   */
  30.                                     /* 1=Use CURRENT, 0=Use GLOBAL     */
  31.  
  32. gdir="Udbase0:Hydra/"               /* Global Hydra UL dir             */
  33.  
  34. reward=2.00                         /* Upload time reward : 0.00=0%,   */
  35.                                     /* 1.00=100%, 1.50=150% etc        */
  36.  
  37. cdaily=1                            /* When user uploads, remove the   */
  38.                                     /* UL:ed byte&file amount from his */
  39.                                     /* downloads of the day. So he     */
  40.                                     /* can DL much more than his daily */
  41.                                     /* limit allows. 1=YES, 0=NO       */
  42.  
  43. SS=1                                /* "Scan selected" at startup      */
  44.                                     /* 1=Yes, 0=No                     */
  45.  
  46. /***************************************************************************/
  47. /*   Nothing worth modifying after this line :)                            */
  48. /***************************************************************************/
  49.  
  50. ver="$VER: Rainbow Hydra 0.2 (26.04.95) by RRR"
  51.  
  52. options results;signal on SYNTAX ; signal on ERROR ; signal on IOERR
  53. if ~show('l','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then signal BYE
  54.  
  55. changewhere "RHydra xfer"
  56.  
  57. getuser 1410474;if ~bittst(d2c(result,4),5) then do      /* Check for shared mode */
  58.     transmit "Sorry, this node is not in the Shared Mode. Nag to SysOp."
  59.     logentry "RHydra - Port is not in SHARED MODE!"
  60.     exit
  61.     end
  62.  
  63. getuser 1310486;device=result;if device='' then do       /* Local Port */
  64.     transmit "Sorry, there is no device defined for that node. Nag to SysOp."
  65.     logentry "RHydra - What the fuck? Port has no device!"
  66.     exit
  67.     end
  68.  
  69. getuser 1410470;serport=result
  70. getuser 1210478;maxbaud=result*10
  71. getuser 1;handle=result                         /* Users handle (for ?logs) */
  72. getuser 12;aika=result                          /* Current time (for ?logs) */
  73. getuser 23;port=result                          /* Port Number */
  74. getuser 24;baud=result*10                       /* Baud Rate of User Online */
  75. getuser 25;gfr=result                      /* Users personal file-ratio #1 */
  76. getuser 26;gbr=result                      /* Users personal byte-ratio #1 */
  77. getuser 1311992;pfdir=result               /* PFile Root Dir */
  78. if usecur=1 then do                        /* Use current dir for uploads! */
  79.          getuser 1306724;curdir=result
  80.          getuser 54;if ~result then call PERSE /* Is UL allowed on this area? */         */
  81. end
  82. if usecur=0 then curdir=gdir               /* Use global hydra UL dir */
  83. getuser 1307954;uudir=result               /* Users own Dir (UUCP Dir) */
  84. getuser 34;avfile=result                   /* Total Available File Credits */
  85. getuser 35;avbyte=result                   /* Total Available Byte Credits */
  86. getuser 1200686;maxdf=result               /* Max downloads (files) per day */
  87. getuser 1400664;maxdb=result               /* Max downloads (bytes) per day */
  88. getuser 1400532;dfoc=result                /* Files downloaded today */
  89. getuser 1400528;dboc=result                /* Bytes downloaded today */
  90.  
  91. /* Infinite file/byte/daily credz? */
  92.  
  93. getuser 1100663;krah=d2c(result+(result<0)*256)
  94. ffdl=BitTST(krah,6);fbdl=BitTST(krah,7)
  95.  
  96. if maxdf=0 then maxdf=99999       /* Should be enough for everyone? */
  97. if maxdb=0 then maxdb=999999999
  98.  
  99. maxdf=maxdf-dfoc
  100. maxdb=maxdb-dboc
  101.  
  102. if SS=1 then do
  103.         transmit "n1Files selected for download:"
  104.         BBSCOMMAND "SS"
  105. end
  106.  
  107. /* Create a Hydra download list - Don't add files if not enough credz */
  108.  
  109. getuser 1401978;sbuf=x2c(d2x(result,8))
  110. fil=uudir'HYDRA.DL';paska="///"
  111. call open(fp,fil,'W');tot=1;getuser 1209644;do a=1 to result
  112.         mullus=0
  113.         tm=import(sbuf,156);sbuf=offset(sbuf,156);parse var tm 5 fi'00'x 36 pt'00'x 136 q 137 fs 138 q 139 br 143 fr +2 .
  114.         file.tot=pt||fi;brate.tot=c2d(br);frate.tot=c2d(fr);mullus=c2d(fs,1)
  115.         if mullus=1 then do
  116.             transmit (fi" is FREE download...")
  117.             freedl.tot=pt||fi
  118.             tot=tot+1
  119.             paska=pt||fi
  120.             call writeln fp, paska
  121.             iterate
  122.             end
  123.         if avfile-frate.tot<0&ffdl=0 then do
  124.             transmit "Not enough file credits for "fi", skipping."
  125.             iterate
  126.             end
  127.         if maxdf-frate.tot<0 then do
  128.             transmit "Not enough daily files for "fi", skipping."
  129.             iterate
  130.             end
  131.         if avbyte-brate.tot<0&fbdl=0 then do
  132.             transmit "Not enough byte credits for "fi", skipping."
  133.             iterate
  134.             end
  135.         if maxdb-brate.tot<0 then do
  136.             transmit "Not enough daily bytes for "fi", skipping."
  137.             iterate
  138.             end
  139.         avfile=avfile-frate.tot;avbyte=avbyte-brate.tot;
  140.         maxdf=maxdf-frate.tot;maxdb=maxdb-brate.tot
  141.         freedl.tot="///"                             /* Not a free dl */
  142.         tot=tot+1;paska=pt||fi
  143.         call writeln fp, paska
  144. end;call close(fp);count=tot
  145.  
  146. if SS=0&paska="///" then transmit "n1No files selected for download, starting anyway..."
  147.  
  148. if exists('pfiles:hydra/banner.txt') then sendfile ('pfiles:hydra/banner.txt')
  149.  
  150. transmit "n1RAiNBOW HYDRA v0.2 ready to transfer, ^X to abort..."
  151.  
  152. setobject 0;putuser 1209644     /* Clear CNet's Select buffer.  */
  153. setobject 1;putuser 1110341     /* FreezeIdle, stop idle timer. */
  154.  
  155. /* Starting HydraCOM (These setups are for Olaf's revision 5) */
  156.  
  157. signal off ERROR
  158. address command 'PFiles:Hydra/HYDRACOM DEV 'device' POR 'serport' SPE 'maxbaud' LIN 'baud' handshake HARD nostamp nobell RES 'pfdir'HydraLog'port' REC 'curdir' SEN @'fil
  159. signal on ERROR
  160.  
  161. setobject 0;putuser 1110341     /* Enable idle timer again.     */
  162.  
  163. call delete(fil)
  164.  
  165. transmit "Transfer complete."
  166. transmit ""
  167.  
  168. bufferflush       /* This removes annoying letters Hydra sends at termination */
  169.  
  170. /* Check for existing logs and facelift Hydra log :) */
  171.  
  172. address command ('sort 'pfdir'HydraLog'port' 'pfdir'HydraLog'port)
  173.  
  174. if exists("sysdata:log/uloads") then do
  175.         call open ulog, "sysdata:log/uloads", 'A'
  176.         uloga=1
  177.         end
  178. if exists("sysdata:log/dloads") then do
  179.         call open dlog, "sysdata:log/dloads", 'A'
  180.         dloga=1
  181.         end
  182.  
  183. /* Adjust credits & other values */
  184.  
  185. tukb=0;tdkb=0;tdf=0;tuf=0;tgive=0
  186. call open(fp,pfdir'HydraLog'port,'R')
  187. do until EOF(fp)
  188.         z=readln(fp);parse var z ttype size . . cps . . . . . name .
  189.  
  190.         if ttype='H' then do                                          /* A download! */
  191.                 call FREEDL                                           /* Check for FREEDL */
  192.                 if vapaad=1 then do
  193.                         logentry "FREEHDL: "name", "size"b, "cps" cps."
  194.                         if dloga=1 then call writeln dlog, ("c2"aika" cc"left(handle,19)" c6H"baud/100" "cps" "left(right(name,12),15)" "size/1000)
  195.                         tdkb=tdkb+size
  196.                         tdf=tdf+1
  197.                 end
  198.                 if vapaad=1 then iterate
  199.         end
  200.  
  201.         if ttype='H' then do
  202.                 getuser 34;setobject result-1;putuser 34              /* Distract credz */
  203.                 getuser 35;setobject result-size;putuser 35
  204.                 getuser 1400532;setobject result+1;putuser 1400532    /* Modify the DL-today variables */
  205.                 getuser 1400528;setobject result+size;putuser 1400528
  206.  
  207.                 logentry "HydraDL: "name", "size"b, "cps" cps."
  208.                 if dloga=1 then call writeln dlog, ("c2"aika" cc"left(handle,19)" c6H"baud/100" "cps" "left(right(name,12),15)" "size/1000)
  209.                 tdkb=tdkb+size
  210.                 tdf=tdf+1
  211.         end
  212.  
  213.         if ttype='R' then do                                          /* An upload! */
  214.                 getuser 34;setobject result+gfr;putuser 34            /* Add credits */
  215.                 getuser 35;setobject result+size*gbr;putuser 35
  216.                 getuser 1200532;setobject result+1;putuser 1200532    /* Modify the UL-today variables */
  217.                 getuser 1200526;setobject result+size;putuser 1200526
  218.  
  219.                 if cdaily=1 then call MAUKKA
  220.  
  221.                 logentry "HydraUL: "name", "size"b, "cps" cps."
  222.                 if uloga=1 then call writeln ulog, ("c2"aika" cc"left(handle,19)" c6H"baud/100" "cps" "left(right(name,12),15)" "size/1000)
  223.  
  224.                 tgive=tgive+((size/cps)/60)*reward
  225.  
  226.                 transmit "Please enter one line description for "name /* Asks for description, adds as a filenote */
  227.                 prompt 78 normal ": ";desc=result
  228.                 address command ('filenote 'curdir||name' "'desc'"')
  229.                 transmit ""
  230.                 tukb=tukb+size
  231.                 tuf=tuf+1
  232.         end
  233.  
  234. end
  235.  
  236. call close(fp);call delete(pfdir'HydraLog'port)
  237.  
  238. if uloga=1 then call close ulog
  239. if dloga=1 then call close dlog
  240. tdkb=tdkb/1000;tukb=tukb/1000
  241.  
  242. addtime tgive
  243.  
  244. getuser 30;setobject result+tukb;putuser 30          /* User's total upload KB add */
  245. getuser 31;setobject result+tuf;putuser 31           /* User's total upload fi add */
  246. getuser 32;setobject result+tdkb;putuser 32          /* User's total download KB add */
  247. getuser 33;setobject result+tdf;putuser 33           /* User's total download fi add */
  248. transmit "Last transfer - UL: "tuf" files, "tukb" kilobytes. (UL time bonus: "tgive" min.)"
  249. transmit "                DL: "tdf" files, "tdkb" kilobytes."
  250. transmit ""
  251.  
  252. exit
  253.  
  254. /* Subroutines */
  255.  
  256. CHECK:;if ARG() & ARG(1)~='###PANIC' then return ARG(1)
  257. getcarrier;if result='TRUE' then if ARG() then return ARG(1);else return
  258. logentry 'Lost Carrier!!';bufferflush;exit
  259.  
  260. ERROR:;IOERR:;SYNTAX:;em='Error in line: 'sigl' Code: 'errortext(rc);logentry em;transmit em;bufferflush;exit
  261.  
  262. PERSE:
  263.     transmit ""
  264.     transmit "Sorry, you are not allowed to upload on this area."
  265.     transmit "Please go to a suitable area and type HYDRA again."
  266.     transmit ""
  267.     exit
  268.  
  269. return
  270.  
  271. MAUKKA:
  272.  
  273.     /* Removes the uploads from user's downloads-of-the-day */
  274.  
  275.     getuser 1400532;setobject result-1;putuser 1400532
  276.     getuser 1400528;setobject result-size;putuser 1400528
  277.  
  278. return
  279.  
  280. FREEDL:
  281.  
  282. tot=0;vapaad=0
  283. do until tot=count
  284.     if name=freedl.tot then vapaad=1
  285.     tot=tot+1
  286. end
  287.  
  288. return
  289.  
  290.  
  291. /***************************************************************************/
  292.